// Copyright (c) 2012 SameGoal LLC.
// All Rights Reserved.
// Author: Andy Hochhaus <ahochhaus@samegoal.com>

// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#ifndef NET_HTTP_SERVER_EVENT_HANDLER_H_
#define NET_HTTP_SERVER_EVENT_HANDLER_H_

#include <string>
#include <vector>

#include "base/basictypes.h"
#include "net/http/server/event/event_server.h"
#include "third_party/libevent/libevent.h"

namespace sg {
namespace net {
namespace http {
namespace server {
namespace event {

class Request;

class Handler {
 public:
  Handler(Callback cb, void *arg);

  bool Run(Request *request);
  struct ProtocolHost {
    std::string host;
    bool encrypted;
  };
  void set_uri_regex(const std::string &uri_regex,
                     std::vector<ProtocolHost> *allowed_hosts);
  void set_not_protocol_host(const std::string &host, const bool encrypted);

 private:
  Callback cb_;
  void *arg_;
  std::string uri_regex_;
  std::vector<ProtocolHost> *protocol_hosts_;
  std::string not_protocol_host_;
  bool not_protocol_encrypted_;

  DISALLOW_COPY_AND_ASSIGN(Handler);
};

}  // namespace event
}  // namespace server
}  // namespace http
}  // namespace net
}  // namespace sg

#endif  // NET_HTTP_SERVER_EVENT_HANDLER_H_
